//
//  XQPositionDetailSecondTableViewCell.swift
//  XiaoQiQiaoSwift
//
//  Created by tech-lab on 2016/11/30.
//  Copyright © 2016年 校企桥. All rights reserved.
//

import UIKit

class XQPositionDetailSecondTableViewCell: UITableViewCell {

    var icon = UIImageView()
    var companyLabel = UILabel()
    var cityLabel = UILabel()
    var sizeLabel = UILabel()
    var typeLabel = UILabel()

    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.accessoryType = .disclosureIndicator
        InitUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    var detailMode : XQPositionDetailPDMode?{
        didSet{
            if ((detailMode?.logo) != nil) {
                let url = URL.init(string: (detailMode?.logo)!)
                icon.kf.setImage(with: url)
            }
        
            companyLabel.text = detailMode?.company_name
            cityLabel.text = detailMode?.area
            typeLabel.text = detailMode?.company_type
            sizeLabel.text = detailMode?.company_size
            
        }
    }
    func InitUI() {
        
        icon = UIImageView.init(frame: CGRect.zero)
        self.contentView .addSubview(icon)
        
        companyLabel = UILabel.init(frame: CGRect.zero)
        self.contentView .addSubview(companyLabel)
                
        cityLabel = UILabel.init(frame: CGRect.zero)
        cityLabel.font = UIFont.systemFont(ofSize: 14)
        self.contentView.addSubview(cityLabel)
        
        typeLabel = UILabel.init(frame: CGRect.zero)
        typeLabel.font = UIFont.systemFont(ofSize: 14)
        self.contentView.addSubview(typeLabel)

        sizeLabel = UILabel.init(frame: CGRect.zero)
        sizeLabel.font = UIFont.systemFont(ofSize: 14)
        self.contentView.addSubview(sizeLabel)

        
        icon.snp.makeConstraints { (make) in
            make.left.equalTo(self.contentView.snp.left).offset(5)
            make.top.equalTo(self.contentView.snp.top).offset(10)
            make.width.equalTo(60)
            make.height.equalTo(60)
        }
        
        companyLabel.snp.makeConstraints { (make) in
            make.left.equalTo(icon.snp.right).offset(5)
            make.top.equalTo(self.contentView.snp.top).offset(10)
        }
        
        cityLabel.snp.makeConstraints { (make) in
            make.left.equalTo(icon.snp.right).offset(5)
            make.bottom.equalTo(icon.snp.bottom)
        }
        
        let line1 = UIView.init(frame: CGRect.zero)
        line1.backgroundColor = UIColor.lightGray
        self.contentView.addSubview(line1)
        
        line1.snp.makeConstraints { (make) in
            make.left.equalTo(cityLabel.snp.right).offset(2)
            make.width.equalTo(0.5)
            make.height.equalTo(15)
            make.centerY.equalTo(cityLabel.snp.centerY)
        }
        
      
        typeLabel.snp.makeConstraints { (make) in
            make.left.equalTo(line1.snp.right).offset(5)
            make.bottom.equalTo(icon.snp.bottom)
        }
        
        let line2 = UIView.init(frame: CGRect.zero)
        line2.backgroundColor = UIColor.lightGray
        self.contentView.addSubview(line2)
        
        line2.snp.makeConstraints { (make) in
            make.left.equalTo(typeLabel.snp.right).offset(2)
            make.width.equalTo(0.5)
            make.height.equalTo(15)
            make.centerY.equalTo(cityLabel.snp.centerY)
        }
        
        sizeLabel.snp.makeConstraints { (make) in
            make.left.equalTo(line2.snp.right).offset(5)
            make.bottom.equalTo(icon.snp.bottom)
        }


        
    }

}
